package com.homework.homework2;import java.net.InetSocketAddress;import java.nio.ByteBuffer;import java.nio.channels.SocketChannel;import java.util.Scanner;/** * Created by aa on 2018/11/14. */public class Client {    public static void main(String[] args) {        try{            SocketChannel sc = SocketChannel.open();            sc.socket().bind(new InetSocketAddress(3366));            sc.connect(new InetSocketAddress("127.0.0.1",8888));            ByteBuffer bb = ByteBuffer.allocate(1024);            Scanner scanner  = new Scanner(System.in);            while (true){                System.out.println("输入信息：");                String str = scanner.next();                bb.clear();                bb.put(str.getBytes());                bb.flip();                sc.write(bb);            }        }catch (Exception e){            e.printStackTrace();        }    }}